﻿using Common;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;

public class MainPanelMng : MonoBehaviour
{
    #region 单例

    public static MainPanelMng Instance
    {
        get
        {
            if (_instance != null) return _instance;

            GameObject go = GameObject.Find("Canvas/MainPanel");
            _instance = go.GetComponent<MainPanelMng>();
            return _instance;
        }
    }

    private static MainPanelMng _instance;

    #endregion

    private Button stickModeBtn;
    private Text stickModeText;

    private CameraObserve camObserve;
    private GameObject stickerSetPanel;

    public bool IsStickMode;

    void Start ()
    {
        this.stickModeBtn = this.transform.Find("StickModeBtn").GetComponent<Button>();
        this.stickModeText = this.stickModeBtn.transform.GetChild(0).GetComponent<Text>();

        this.stickerSetPanel = this.transform.Find("StickerSetPanel").gameObject;
        this.camObserve = Camera.main.transform.GetComponent<CameraObserve>();
        this.stickModeBtn.onClick.AddListener(this.StickModeBtnClick);
        this.IsStickMode = false;
        this.stickerSetPanel.SetActive(false);
    }

    private void StickModeBtnClick()
    {
        this.IsStickMode = !this.IsStickMode;
        if (this.IsStickMode)
        {
            this.stickModeText.text = "退出贴纸模式";
            this.stickerSetPanel.SetActive(true);
        }
        else
        {
            this.stickModeText.text = "进入贴纸模式";
            this.stickerSetPanel.SetActive(false);
            DrawRectangleMng.Instance.SelectBoxMng.gameObject.SetActive(false);
            DrawRectangleMng.Instance.Iron.SetActive(false);
        }

        DrawRectangleMng.Instance.IsStickMode = this.IsStickMode;
        this.camObserve.ChangeCameraProjection(this.IsStickMode);
    }
}
